package
{
    import flash.display.*;
    import flash.events.*;

    import model.GameModelLocator;
    import model.vo.GameVo;
    import view.*;

    [SWF(width="640", height="480", backgroundColor="#000000")]
    public class Main extends Sprite
    {
        private var gameVo:GameVo;

        private var backFrame:BackFrame;
        private var coverPage:CoverPage;
        private var introduction:Introduction;
        private var game:Game;

        public function Main()
        {
            gameVo = GameModelLocator.getInstance().gameVo;

            coverPage = new CoverPage();
            coverPage.addEventListener(MouseEvent.MOUSE_DOWN, gotoIntroduction);
            addChild(coverPage);

            backFrame = new BackFrame();
            backFrame.x = 320;
            backFrame.y = 240;
            backFrame.display();
            backFrame.mouseEnabled = false;
            addChild(backFrame);
        }

        private function gotoIntroduction(e:Event):void
        {
            coverPage.removeEventListener(MouseEvent.MOUSE_DOWN, gotoIntroduction);
            removeChild(coverPage);
            removeChild(backFrame);
            introduction = new Introduction();
            introduction.addEventListener(MouseEvent.MOUSE_DOWN, gotoGame);
            addChild(introduction);
            addChild(backFrame);
        }

        private function gotoGame(e:Event):void
        {
            introduction.removeEventListener(MouseEvent.MOUSE_DOWN, gotoGame);
            removeChild(introduction);
            removeChild(backFrame);
            game = new Game();
            game.x = 320;
            game.y = 240;
            addChild(game);

            addChild(backFrame);
        }
    }
}
